package com.zyy.server;

import com.zyy.service.HelloServiceImpl;
import com.zyy.service.IHelloService;

import java.net.MalformedURLException;
import java.rmi.AlreadyBoundException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;

/**
 * @author zyy
 * @date 2021/1/26 下午5:59
 * @description
 */
public class RMIServer {
    public static void main(String[] args) throws RemoteException, AlreadyBoundException, MalformedURLException {
        //1.创建HelloService实例
        IHelloService helloService = new HelloServiceImpl();
        //2.获取注册表
        LocateRegistry.createRegistry(8888);
        //3.对象的绑定
        //bind方法的 参数1：rmi://ip地址:端口/服务名  参数2：绑定的对象
        Naming.bind("//127.0.0.1:8888/rmiserver",helloService);
    }
}
